import React, { Component } from 'react'

export default class App extends Component {

  constructor(props){
    super(props)

    // 可以在构造函数中进行 this 执向的修改
    this.add = this.add.bind(this)
  }

  state = {
    count: 100
  }

  add = function(){
    console.log('你好世界',this);
    this.setState({
      count: this.state.count + 8
    })
  }

  addNum = function(){
    console.log('你好中国',this);
  }

  render() {
    return (
      <div>
        <h1>App -- {this.state.count}</h1>
        <button onClick={this.add}>点击增加</button>

        {/* 推荐写法 */}
        <button onClick={()=>{this.addNum()}}>点击增加</button>

      </div>
    )
  }
}
